PROJECT(CMakes)
# REQUIRE
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)

# some useful variables  http://www.cmake.org/Wiki/CMake_Useful_Variables

#SET(CMAKE_INSTALL_PREFIX $ENV{HOME}/.local/)
SET(GLO_VERSION_MAJOR 1)
SET(GLO_VERSION_MINOR 0.1)

SET(VERSION 0.1)
SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE on)
SET(CMAKE_INCLUDE_CURRENT_DIR on)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH on)

SET(CMAKE_MACOSX_RPATH 1)
MESSAGE(STATUS "CMAKE_INSTALL_PREFIX " ${CMAKE_INSTALL_PREFIX})
MESSAGE(STATUS "CMAKE_MACOSX_RPATH " ${CMAKE_MACOSX_RPATH})

MESSAGE(STATUS "BINARY_DIR " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "SOURCE_DIR " ${PROJECT_SOURCE_DIR})


SET(GLFW_ROOT "lib/glfw")
# glfw options setting 
SET(GLFW_BUILD_EXAMPLES NO)
SET(GLFW_BUILD_TESTS NO)
SET(GLFW_BUILD_DOCS NO)
SET(GLFW_INSTALL NO)

ADD_SUBDIRECTORY(${GLFW_ROOT} "lib/build")
INCLUDE_DIRECTORIES(${GLFW_ROOT}/include)



# REQUIREMENT CHECKER 
FIND_PACKAGE(PkgConfig)
# PKG_CHECK_MODULES(GLIB2 REQUIRED glib-2.0>=2.10)
# PKG_CHECK_MODULES(LIBEVENT REQUIRED libevent)
#set(Boost_USE_STATIC_LIBS        ON)
#set(Boost_USE_MULTITHREADED      ON)
#set(Boost_USE_STATIC_RUNTIME    OFF)
#find_package(Boost COMPONENTS thread filesystem system program_options REQUIRED)

# general flags 
# SET(CMAKE_C_FLAGS "$ENV{CFLAGS}  -Wall -g -ggdb --std=c99 -v")
SET(CMAKE_C_FLAGS "$ENV{CFLAGS}  -Wall -g -ggdb --std=c99")
#SET(CMAKE_CXX_FLAGS " $ENV{CXXFLAGS}  -Wall -g -ggdb --std=c++11 -Wno-deprecated")
SET(CMAKE_CXX_FLAGS " $ENV{CXXFLAGS}  -Wall -g -ggdb --std=c++11")
# debug cmake  -DCMAKE_BUILD_TYPE=debug ..
SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS}  -Wall -g -ggdb --std=c99")
SET(CMAKE_CXX_FLAGS_DEBUG " $ENV{CXXFLAGS}  -Wall -g -ggdb --std=c++11")
# release cmake  -DCMAKE_BUILD_TYPE=release ..
SET(CMAKE_C_FLAGS_RELEASE " $ENV{CFLAGS}  -Wall  -O3 --std=c99")
SET(CMAKE_CXX_FLAGS_RELEASE " $ENV{CXXFLAGS} -Wall -O3 --std=c++11")

SET (RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")

## OpenGL
FIND_PACKAGE(OpenGL REQUIRED)
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})



LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})


#PKG_SEARCH_MODULE(GLFW REQUIRED glfw3)
#INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIRS})
#MESSAGE(STATUS "FIND GLFW_INCLUDE_DIRS " ${GLFW_INCLUDE_DIRS})


# INCLUDE DIRECTORIES
INCLUDE_DIRECTORIES(
	${PROJECT_SOURCE_DIR}/include
	${PROJECT_BINARY_DIR}/include
)


# LINK DIRECTORIES
LINK_DIRECTORIES(
	${PROJECT_BINARY_DIR}/lib
)

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)



ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(lib)
ADD_SUBDIRECTORY(src)





